<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/3/15
 * Time: 11:54
 */

namespace app\common\model;
use think\Model;

class SetMoney extends Model
{
    protected $name = "set_money";

    public function addMoneyInfo($data) {

        $res = $this->insert($data);

        return $res;
    }

    public function getMoneyInfoList($where, $field, $keyword, $request, $limit) {
        if ($keyword) {
            $data = $this
                ->field($field)
                ->where($where)
                ->whereOr('type_name|id','like',"%$keyword%")
                ->order('create_time desc')
                ->paginate($limit, false, ['query' => $request->get()]);
        } else {
            $data = $this
                ->field($field)
                ->where($where)
                ->order('create_time desc')
                ->paginate($limit, false, ['query' => $request->get()]);
        }

        return $data;
    }

    public function getMoneyInfo ($where, $field){

        $info = $this->field($field)->where($where)->find();

        return $info;
    }

    public function updateMoneyInfo ($where, $data) {

        $res = $this->where($where)->update($data);

        return $res;
    }
}